package controller

import (
	"github.com/gin-gonic/gin"
	"go.web.demo.com/api/pojo"
	"go.web.demo.com/web/model"
	"go.web.demo.com/web/rpc_client"
	"strconv"
)

// ActivityRoute 路由配置
func ActivityRoute(g *gin.RouterGroup) {
	g.GET("/getOneActivity", getOneActivity)

}

func getOneActivity(c *gin.Context) {
	strId := c.Query("id")
	id, err := strconv.Atoi(strId)
	if err != nil {
		SuccessJson(c, model.RequestError("id不能为空,并且只能为数字"))
		return
	}
	param := &pojo.ActivityParam{Id: int64(id)}
	activity := rpc_client.QueryOneActivity(param)
	if activity.Id == 0 {
		SuccessJson(c, model.Fail("记录不存在"))
		return
	}
	SuccessJson(c, model.Success(activity))

}
